package com.xyang.demo.dao;

import com.xyang.demo.entity.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Stars-Of-Future-xYang
 * @version 1.0
 * @date 2021/3/18 15:53
 */

@Mapper
public interface DepartmentMapper {

    @Select("select * from t_department where id =#{id}")
    @Results(id="selectById",value = {@Result(column = "id",id = true,property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "id",property = "users",many =@Many(select ="com.xyang.demo.dao.UserMapper.findByDId"))})
    Department findById(Integer id);

    @ResultMap("selectById")
    @Select("select * from t_department")
    List<Department> findAll();
}
